package com.x25175.file.service;

import com.x25175.file.entity.User;
import com.x25175.file.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 徐佳辉
 * @date 2020/11/18 15:54
 */
@Service
@Slf4j
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public boolean deleteByPrimaryKey(Integer userId) {
        int i = userMapper.deleteByPrimaryKey(userId);
        return i > 0;
    }


    public boolean insert(User user) {
        log.info("user:[{}]", user);
        int insert = userMapper.insert(user);
        return insert > 0;
    }

    public boolean insertSelective(User user) {
        int i = userMapper.insertSelective(user);
        return i > 0;
    }

    public boolean updateByPrimaryKeySelective(User user) {
        int i = userMapper.updateByPrimaryKeySelective(user);
        return i > 0;
    }

    public boolean updateByPrimaryKey(User user) {
        int i = userMapper.updateByPrimaryKey(user);
        return i > 0;
    }

    public User selectByUserId(Integer userId) {
        User user = userMapper.selectByUserId(userId);
        return user;
    }


    public User selectByUserName(String name) {
        User user = userMapper.selectByUserName(name);
        return user;
    }
}
